import axios from "axios";

const service = axios.create({
  baseURL: 'http://10.205.32.219:8888',
  timeout: 5000
});

service.interceptors.response.use(
  response => {
    if (response.status == 200) {
      if (response.data.code == 200) {
        return response.data.data;
      } else {
        return response.data;
      }
    } else {
      return [];
    }
  },
  error => {
    return Promise.reject([]);
  }
);

export function getPointDatas(obj) {
  return service({
    url: "/api/list?pointId=" + obj.id + "&startTime=" + obj.st + "&endTime=" + obj.et,
    method: "GET"
  });
}
export function downDatas(obj) {
  return service({
    url: "/down/datas?pointId=" + obj.id + "&startTime=" + obj.st + "&endTime=" + obj.et,
    method: "GET",
    responseType: 'blob'
  });
}
// location /api/list {
//   proxy_pass http://10.205.48.134:8080/pointData/list;
// }
// location /down/datas {
//   proxy_pass http://10.205.48.134:8080/pointData/export-pointData;
//   添加以下行来设置 Content-Disposition 头
//   add_header Content-Disposition 'attachment; filename="export.xlsx"';
// }